package com.springmq.mq.thread;

import com.sun.jndi.toolkit.url.Uri;
import lombok.Data;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URL;

/**
 * @ClassName : ImagesThread
 * @Author : lby
 * @Date: 2021/1/29 14:27
 * @Description : 多线程图片下载
 */
@Slf4j
@Data
public class ImagesThread extends Thread {
    private URL uri;
    private File file;
    @SneakyThrows
    @Override
    public void run() {
        this.downloadPages();
    }

    public void downloadPages() throws IOException {
        FileUtils.copyURLToFile(uri,file);
    }
}
